package com.test.sshshiro.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.test.sshshiro.entity.AcctUser;
import com.test.sshshiro.framework.BaseController;
import com.test.sshshiro.framework.page.Page;
import com.test.sshshiro.framework.web.Flash;
import com.test.sshshiro.service.AcctUserService;
import com.test.sshshiro.vo.query.AcctUserQuery;

@Controller
@RequestMapping("acctUser")
public class AcctUserController extends BaseController{

protected static final String DEFAULT_SORT_COLUMNS = null; 
	
	@Autowired
	private AcctUserService acctUserService;
	
private final String LIST_ACTION = "redirect:/acctUser/list";
	
	public AcctUserController() {
	}
	
	/** 
	 * 执行搜索 
	 **/
	@RequestMapping(value="/list")
	public ModelAndView list(HttpServletRequest request,AcctUserQuery query) {
		String mode = request.getParameter("mode");
		
		
		Page page = this.acctUserService.findPage(query);
		request.getSession().setAttribute(AcctUserQuery.class.getSimpleName(), query);
		ModelAndView result = new ModelAndView("/AcctUser/list");
		ModelMap map = toModelMap(page, query);
		result.addAllObjects(map);
		return result;
	}
	
	/** 
	 * 查看对象
	 **/
	@RequestMapping(value="/show")
	public ModelAndView show(HttpServletRequest request) throws Exception {
		java.lang.Long id = new java.lang.Long(request.getParameter("id"));
		AcctUser acctUser = (AcctUser)acctUserService.getById(id);
		if(acctUser == null){			
			Flash.current().error("error.record.notfound");
			return new ModelAndView("redirect:/acctUser/list");
		}
		return new ModelAndView("/AcctUser/show","acctUser",acctUser);
	}
}
